<?php
/**
 * Yii-user and rights initial records
 * 
 * @package Database\Migrations
 */
 class m140129_175117_user_rights_fixtures extends CDbMigration {
 
	public function up() {
		$this->insert('tbl_user', array(
			'id'           => 1,
			'username'     => 'admin',
			'password'     => 'b63c01d83f47dd4f9034ac9c409b98e3', //unholy
			'email'        => 'mfalero@mail.com',
			'activkey'     => '6a0f115ce8e37f37a5405e4a26545876',
			'superuser'    => 1,
			'status'       => 1,
			'create_at'    => '2014-01-29 15:04:40',
			'lastvisit_at' => '2014-01-29 15:49:29',
		));
		
		$this->insert('tbl_profile', array(
			'user_id'    => 1,
			'first_name' => 'Administrator',
			'last_name'  => 'Admin'
		));
		
		$this->insert('tbl_profile_field', array(	
			'id'              => 1,
			'varname'         => 'first_name',
			'title'           => 'First Name',
			'field_type'      => 'VARCHAR',
			'field_size'      => 255,
			'field_size_min'  => 3,
			'required'       => 2,
			'match'           => '',
			'range'           => '',
			'error_message'   => 'Incorrect First Name (length between 3 and 50 characters).',
			'other_validator' => '',
			'default'         => '',
			'widget'          => '',
			'widgetparams'    => '',
			'position'        => 1,
			'visible'         => 3,
		));

	$this->insert('tbl_profile_field', array(	
			'id'              => 2,
			'varname'         => 'last_name',
			'title'           => 'Last Name',
			'field_type'      => 'VARCHAR',
			'field_size'      => 255,
			'field_size_min'  => 3,
			'required'       => 2,
			'match'           => '',
			'range'           => '',
			'error_message'   => 'Incorrect Last Name (length between 3 and 50 characters).',
			'other_validator' => '',
			'default'         => '',
			'widget'          => '',
			'widgetparams'    => '',
			'position'        => 2,
			'visible'         => 3,
		));
		
		$this->insert('tbl_auth_item', array(
			'name'        => 'Admin',
			'type'        => 2,
			'description' => 'Administrator',
		));

		$this->insert('tbl_auth_item', array(
			'name'        => 'Auth',
			'type'        => 2,
			'description' => 'Authenticated',
		));

		$this->insert('tbl_auth_item', array(
			'name'        => 'Unauth',
			'type'        => 2,
			'description' => 'Unauthenticated',
		));

		$this->insert('tbl_auth_item', array(
			'name'        => 'User.Login.Login',
			'type'        => 0,
			'description' => null,
		));
		
		$this->insert('tbl_auth_item_child', array(
			'parent' => 'Unauth',
			'child'  => 'User.Login.Login',
		));
		
		$this->insert('tbl_auth_assignment', array(	
			'itemname' => 'Admin',
			'userid'  => 1
		));

	}

	public function down()
	{
		echo "m140129_175117_user_rights_fixtures does not support migration down.\n";
		return false;
	}

	/*
	// Use safeUp/safeDown to do migration with transaction
	public function safeUp()
	{
	}

	public function safeDown()
	{
	}
	*/
}